package net.csdn.business.notify.handler.pending;


import lombok.Data;
import lombok.experimental.Accessors;
import lombok.extern.slf4j.Slf4j;
import net.csdn.business.notify.common.enums.ProcessTypeEnum;
import net.csdn.business.notify.common.model.vo.NotifyResponseVO;
import net.csdn.business.notify.common.pipeline.ProcessContext;
import net.csdn.business.notify.common.pipeline.ProcessController;
import net.csdn.business.notify.common.pipeline.domain.ProcessModel;
import net.csdn.business.notify.common.pipeline.domain.TaskInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;


/**
 * @ClassName DirectTask
 * @Description 直达的task执行器
 * @Author zhangyl
 * @Date 2023/12/20 14:41
 */
@Data
@Accessors(chain = true)
@Slf4j
@Component
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class DirectTask implements Runnable {
    private TaskInfo taskInfo;
    @Autowired
    @Qualifier("handlerProcessController")
    private ProcessController processController;

    @Override
    public void run() {
        ProcessContext<ProcessModel> context = ProcessContext.builder()
                .processModel(taskInfo)
                .processType(ProcessTypeEnum.HANDLER_DIRECT_NOTIFY.getCode())
                .needBreak(false).response(NotifyResponseVO.success())
                .build();
        processController.process(context);
    }
}
